package org.codersunit.radboid.data;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class BasicLecture implements Lecture {
	private Calendar start;
	private Calendar end;
	private int duration;
	private String name;
	private String code;
	private String type;
	private String location;
	private String lecturer;
	private String remark;
	
	public void setStart(Calendar start) {
		this.start = start;
		end = null;
	}
	
	public void setDuration(int seconds) {
		duration = seconds;
		end = null;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public void setType(String type) {
		this.type = type;
	}
	
	public void setLocation(String location) {
		this.location = location;
	}
	
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	public void setLecturer(String lecturer) {
		this.lecturer = lecturer;
	}
	
	@Override
	public Calendar getStart() {
		return start;
	}

	@Override
	public Calendar getEnd() {
		if(end == null && start != null) {
			end = new GregorianCalendar();
			end.setTime(start.getTime());
			end.add(Calendar.SECOND, duration);
		}
		return end;
	}

	@Override
	public Date getStartDate() {
		if(start != null) {
			return start.getTime();
		}
		return null;
	}

	@Override
	public Date getEndDate() {
		if(end != null) {
			return end.getTime();
		}
		return null;
	}

	@Override
	public int getDuration() {
		return duration;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String getRemark() {
		return remark;
	}

	@Override
	public String getLecturer() {
		return lecturer;
	}

	@Override
	public String getLocation() {
		return location;
	}

	@Override
	public String getCode() {
		return code;
	}

	@Override
	public String getFullName() {
		return code + " " + name;
	}

	@Override
	public String getType() {
		return type;
	}

	@Override
	public String getCourseId() {
		return code;
	}

	@Override
	public String getLectureStreamId() {
		return start.get(Calendar.DAY_OF_WEEK) + start.get(Calendar.HOUR_OF_DAY) + ":" + 
			start.get(Calendar.MINUTE) + code;
	}

	@Override
	public boolean isVisible() {
		return true;
	}

}
